import { get, post, put, del } from '../../utils/request';

const WX_CONST = {
  appid: 'wx4d7943b028ad3a61',
  secret: '5607d875f834bf4583e1bcc333c7fee9',
  grant_type: 'authorization_code'
};

export function getWeChatToken(code) {
  return get('/wx/oauth2/access_token', { ...WX_CONST, code });
}
export function getWeChatUserInfo(access_token, openid) {
  return get('/wx/userinfo', { access_token, openid });
}
export function sendSMS(mobile, action) {
  return post('v1/auth/code/sms', { mobile, action })
}
export function logout() {
  return post('v1/user/logout')
}
export function loginMobile(params) {
  return post('v1/user/login/mobile', params)
}
export function loginWechat(params) {
  return post('v1/user/login/wechat', params)
}
export function updateUserInfo(params) {

  return put('v1/user/insurance-org', params);
}
export function bindWechat(params) {
  return put('v1/user/bind-wechat', params);
}
export function bindMobile(params) {
  return put('v1/user/bind-mobile', params);
}
export function getPosts(id) {
  return get(`v1/user/insurance-org/${id}/posts`);
}
export function getApplyStatus() {
  return get('v1/user/insurance-org/applied-for-join/awaiting-approval');
}
export function getMe() {
  return get('v1/user/me');
}
export function getSmsTemplate() {
  return get('v1/user/sms-template');
}
export function updateSmsTemplate(smsTemplate) {
  return put('v1/user/sms-template', {smsTemplate});
}
